<?php

http://www.tietuku.com/open
09:44
阳顶天
顶天
//上传贴图库
function tietu($img_url=null){

    if ($img_url == NULL){
        return false;
    }
    $url = C(TIETU_URL);
    $data = array('deadline' => NOW_TIME+60,
                   'aid' => '1293737',
                   'from' => 'web',
                   'httptype' => 1,
                   'Token' => C(TIETU_TOKEN),
                   'fileurl' => $img_url,
        );    
    $ch = curl_init();  
  
    curl_setopt($ch, CURLOPT_URL, $url);  
    curl_setopt($ch, CURLOPT_POST, 1);  
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);  
    curl_setopt($ch, CURLOPT_AUTOREFERER, 1);  
    curl_setopt($ch, CURLOPT_MAXREDIRS, 4);  
    curl_setopt($ch, CURLOPT_ENCODING, ""); //必须解压缩防止乱码  
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 5.1; zh-CN) AppleWebKit/535.12 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/535.12");  
    curl_setopt($ch, CURLOPT_TIMEOUT, 15);  
  
    $output = curl_exec($ch);  
    curl_close($ch);  
    return json_decode($output,true);
}

/* 检测远程图片是否200 */
function img_exists($url) {
    $result = @fopen( $url, 'r' );
    if (false !== $result){
        return TRUE;
    }else{
        return FALSE;
    }
}


/* 是否存在fttp */
function has_http($str){
    
    return strpos($str,'http') === 0;
}